package com.feng.financial.seller.config;

import com.feng.financial.api.service.ProductRpcService;
import com.googlecode.jsonrpc4j.spring.AutoJsonRpcClientProxyCreator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author Administrator
 */
@Configuration
public class RpcConfig {

    public static final Logger LOGGER = LoggerFactory.getLogger(RpcConfig.class);

    @Bean
    public AutoJsonRpcClientProxyCreator autoJsonRpcClientProxyCreator(@Value("${rpm.manager.url}") String url){
        AutoJsonRpcClientProxyCreator creator = new AutoJsonRpcClientProxyCreator();
        try {
            creator.setBaseUrl(new URL(url));
        } catch (MalformedURLException e) {
            LOGGER.error("远程URL错误 ：" + url);
        }
        creator.setScanPackage(ProductRpcService.class.getPackage().getName());
        return creator;
    }

}
